#![no_std]
#![no_main]

use panic_halt as _;
use cortex_m_rt::entry;
use stm32f4xx_hal::{
    pac,             //外围外设访问crate
    prelude::*,             
};

#[entry]
fn main() -> ! {
    //获取外围外设设备控制权（单例模式）
    let dp = pac::Peripherals::take().unwrap();

    //1.时钟配置
    let rcc = dp.RCC.constrain();

    // 正确配置 48MHz 时钟树
    let clocks = rcc.cfgr.use_hse(8.MHz()).sysclk(48.MHz()).freeze();

    //分解GPIOF寄存器
    let gpiof = dp.GPIOF.split();

    //设置PF9和PF10为推挽输出模式
    let mut led_0 = gpiof.pf9.into_push_pull_output();
    let mut led_1 = gpiof.pf10.into_push_pull_output();
    led_0.set_low();
    led_1.set_low();

    //延时
    let mut delay = dp.TIM2.delay_ms(&clocks);

    loop {
        led_0.toggle();
        led_1.toggle();
        delay.delay_ms(1000u32);
    }
}
